import sys
xinbei = input("输入性别")
height = input("输入身高（M）：")
#height = (eval(height[:-1]))
weight = input("输入体重（KG）：")
#weight = (eval(weight[:-2]))
#weight = weight[:-2]
#weight = eval(weight)


def 判断bmi():
    if 性别 == "男":
        if bmi < 17.5:
            who, nat = "厌食症", "厌食症"
        elif bmi < 20.7:
            who, nat = "体重不足", "体重不足"
        elif 20.7 <= bmi < 26.4:
            who, nat = "正常", "偏胖"
        elif 26.4 <= bmi < 27.8:
            who, nat = "轻度超重", "轻度超重"
        elif 27.8 <= bmi < 31.1:
            who, nat = "超重", "超重"
        else:
            who, nat = "肥胖", "肥胖"
    if 性别 == "女":
        if bmi < 17.5:
            who, nat = "厌食症", "厌食症"
        elif bmi < 19.1:
            who, nat = "体重不足", "体重不足"
        elif 19.1 <= bmi < 25.8:
            who, nat = "正常", "偏胖"
        elif 25.8 <= bmi < 27.3:
            who, nat = "轻度超重", "轻度超重"
        elif 27.3 <= bmi < 32.3:
            who, nat = "超重", "超重"
        else:
            who, nat = "肥胖", "肥胖"
    print("BMI指标国际'{0}', 国内'{1}'".format(who,nat))


if height[-1] in ["M", "m"] and weight[-2:] in ["kg", "KG"] and 性别 in ["男","女"]:
    height = (eval(height[:-1]))
    weight = (eval(weight[:-2]))
    bmi = weight / pow(height, 2)
    print("BMI 数值：{:.2f}".format(bmi))
    who, nat = "", ""
    判断bmi()
else:
    print("出错")

QX = input("是否继续（YES/NO）:")
while QX == "YES":
    性别 = input("输入性别")
    height = input("输入身高（M）：")
    weight = input("输入体重（KG）：")
    if height[-1] in ["M", "m"] and weight[-2:] in ["kg", "KG"]:
        height = (eval(height[:-1]))
        weight = (eval(weight[:-2]))
        bmi = weight / pow(height, 2)
        print("BMI 数值：{:.2f}".format(bmi))
        who, nat = "", ""
    else:
        print("出错")
    判断bmi()
while QX == "NO":
    sys.exit(0)

